package com.ruoyi.web.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
import com.ruoyi.web.domain.GuEveryDay;
import com.ruoyi.web.service.IGuEveryDayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 每日行情Controller
 * 
 * @author ruoyi
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/day")
public class GuEveryDayController extends BaseController
{
    @Autowired
    private IGuEveryDayService guEveryDayService;

    /**
     * 查询每日行情列表
     */
    @RequiresPermissions("system:day:list")
    @GetMapping("/list")
    public TableDataInfo list(GuEveryDay guEveryDay)
    {
        startPage();
        List<GuEveryDay> list = guEveryDayService.selectGuEveryDayList(guEveryDay);
        return getDataTable(list);
    }

    /**
     * 导出每日行情列表
     */
    @RequiresPermissions("system:day:export")
    @Log(title = "每日行情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuEveryDay guEveryDay)
    {
        List<GuEveryDay> list = guEveryDayService.selectGuEveryDayList(guEveryDay);
        ExcelUtil<GuEveryDay> util = new ExcelUtil<GuEveryDay>(GuEveryDay.class);
        util.exportExcel(response, list, "每日行情数据");
    }

    /**
     * 获取每日行情详细信息
     */
    @RequiresPermissions("system:day:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(guEveryDayService.selectGuEveryDayById(id));
    }

    /**
     * 新增每日行情
     */
    @RequiresPermissions("system:day:add")
    @Log(title = "每日行情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GuEveryDay guEveryDay)
    {
        return toAjax(guEveryDayService.insertGuEveryDay(guEveryDay));
    }

    /**
     * 修改每日行情
     */
    @RequiresPermissions("system:day:edit")
    @Log(title = "每日行情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GuEveryDay guEveryDay)
    {
        return toAjax(guEveryDayService.updateGuEveryDay(guEveryDay));
    }

    /**
     * 删除每日行情
     */
    @RequiresPermissions("system:day:remove")
    @Log(title = "每日行情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(guEveryDayService.deleteGuEveryDayByIds(ids));
    }

    /**
     * 获取每日行情详细信息 --从 腾讯服务器
     */
    @GetMapping("/getTengxun")
    @RequiresPermissions("system:day:query")
    public AjaxResult getInfoFromTengXun()
    {
        return success(guEveryDayService.getDataFromTengXun());
    }

}
